#ifndef AI_AGENT_H_INCLUDED
#define AI_AGENT_H_INCLUDED

#include "Behaviour.h"
#include "Vec3.h"
#include <vector>
#include <map>
#include "GameObject.h"

class AIAgentGroup;
class AIState;

class AIAgent : public GameObject
{
public:

	typedef std::pair<Behaviour*, float> BehaviourAndWeight;
	typedef std::map<Behaviour*, float> BehaviourAndWeightMap;


	AIAgent();
	//AIAgent( Vec3f pos, float mass, float maxSpeed, float maxForce, float maxTurnRate);
	virtual ~AIAgent() {}
	
	void Update() = 0;
	virtual void Draw() {};
	
	void SetBehaviourAndWeights(BehaviourAndWeightMap& behaviours);
	void SetAIState(AIState* state);

	void DecideBehaviour();
	void AddBehaviour(Behaviour& newBehaviour);
	void RemoveBehaviour(Behaviour& behaviour);
	void ApplyForce(Vec3f& force);

	float GetMaxSpeed() const;
	float GetMaxForce() const;
	float GetVisionRadius() const;
	
	AIState* GetAIState();
	void SetGroup(AIAgentGroup* group);
	std::vector<AIAgent*>* GetNeighbours();
	
	//void SetAIState(AIState* state);

protected:
	float m_maxSpeed;
	float m_maxForce;
	float m_maxTurnRate;

	float m_visionRadius;
	
	Vec3f m_heading;
	Vec3f m_sideVec;
	Vec3f m_combinedForce;
	
	AIState* m_pAIState;
	AIAgentGroup* m_pGroup;
	std::vector<AIAgent*> m_neighbours;
	
	BehaviourAndWeightMap m_behaviourMap;

	bool m_debugDrawForces;

	//typedef std::map<std::string, BehaviourAndWeight> BehaviourAndWeightMap;
	//BehaviourAndWeightMap m_behaviourMap;
};

#endif